import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/unit',
    component: Layout,
    redirect: '/unit/college',
    name: '单位管理',
    meta: { title: '单位管理', icon: 'example' },
    children: [
      {
        path: '/college',
        name: '学院管理',
        component: () => import('@/views/college/list'),
        meta: { title: '学院管理', icon: 'table' }
      },
      {
        path: '/class',
        name: '班级管理',
        component: () => import('@/views/class/list'),
        meta: { title: '班级管理', icon: 'table' }
      }
    ]
  },
  {
    path: '/userList',
    component: Layout,
    redirect: '/student/list',
    name: '用户管理',
    meta: { title: '用户管理', icon: 'example' },
    children: [
      {
        path: 'studentList',
        name: '学生管理',
        component: () => import('@/views/student/list'),
        meta: { title: '学生管理', icon: 'table' }
      },
      {
        path: 'teacherList',
        name: '老师管理',
        component: () => import('@/views/teacher/list'),
        meta: { title: '老师管理', icon: 'table' }
      }
    ]
  },

  {
    path: '/holiday',
    component: Layout,
    children: [
      {
        path: '/holiday/list',
        name: '请假管理',
        component: () => import('@/views/holiday/list'),
        meta: { title: '请假管理', icon: 'form' }
      }
    ]
  },
  {
    path: '/course',
    component: Layout,
    children: [
      {
        path: '/course/list',
        name: '签到管理',
        component: () => import('@/views/course/courseList'),
        meta: { title: '签到管理', icon: 'form' }
      }
    ]
  },
  {
    path: '/notice',
    component: Layout,
    children: [
      {
        path: '/notice/add',
        name: '通知管理',
        component: () => import('@/views/notice/add'),
        meta: { title: '通知管理', icon: 'form' }
      }
    ]
  },
  {
    path: '/fileUpload',
    component: Layout,
    redirect: '/fileUpload/taskList',
    name: '文件上传与管理',
    meta: { title: '文件上传与管理', icon: 'example' },
    children: [
      {
        path: 'taskList',
        name: '文件任务列表',
        component: () => import('@/views/fileUpload/taskList'),
        meta: { title: '文件任务列表', icon: 'table' }
      },
      {
        path: 'upload',
        name: '文件上传',
        component: () => import('@/views/fileUpload/upload'),
        meta: { title: '文件上传', icon: 'table' }
      },
      {
        path: 'fileList',
        name: '文件列表',
        component: () => import('@/views/fileUpload/fileList'),
        meta: { title: '文件列表', icon: 'table' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
